package com.bohua.child.controller;

import com.bohua.child.common.Lay;
import com.bohua.child.common.Msg;
import com.bohua.child.entity.Student;
import com.bohua.child.service.StudentService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
/**
 * 学生信息表控制器
 * @author shichenyang
 * @email gyv12345@163.com
 * @date 2019/01/17
 */
@Controller
@RequestMapping("/student")
public class StudentController {
    @Resource
    private StudentService studentService;

    @RequestMapping
    public String student(){
        return "student/student.html";
    }
    @RequestMapping("/add")
    public String add(){
        return "student/addStudent.html";
    }

    @RequestMapping("/update")
    public String update(){
        return "student/updateStudent.html";
    }

    @RequestMapping("/getStudents")
    @ResponseBody
    public Lay getStudents(Student student,Integer page,Integer limit){
        return studentService.getStudents(student,page,limit);
    }
    @RequestMapping("/addStudent")
    @ResponseBody
    public Msg addStudent(Student student){
        return studentService.addStudent(student);
    }

    @RequestMapping("/updateStudent")
    @ResponseBody
    public Msg updateStudent(Student student){
        return studentService.updateStudent(student);
    }

    @RequestMapping("/delStudent")
    @ResponseBody
    public Msg delStudent(Student student){
        return studentService.delStudent(student);
    }
}
